//
//  LGMedicineRecordController.m
//  HeartDiseaseManage
//
//  Created by 1234 on 2023/10/9.
//  服药统计

#import "LGMedicineRecordController.h"
#import "LGMedicineRecordChartView.h"
@interface LGMedicineRecordController ()<LGMedicineRecordChartDelegate>
/**   */
@property (nonatomic , strong)LGMedicineRecordChartView *chartView;
/**   */
@property (nonatomic , assign)NSInteger index;
@end

@implementation LGMedicineRecordController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.chartView];
    [self requestData];
}

-(void)requestData{
    [RequestUtil withPOST:@"/doctor/Sportsprescription.MedicinePrescription/medicineStatistics" parameters:@{@"patient_id":self.patientid} withSign:YES success:^(NSInteger code, NSString *message, id returnData) {
        if(code == 200){
            self.chartView.medicineArray = returnData[@"medicines"];
            self.chartView.dataDic = returnData[@"column_chats"];
        }
    } error:^(NSError *error) {
        
    }];
}

-(void)requestMedicine:(NSString *)medicineid index:(NSInteger)index{
    self.index = index;
    [RequestUtil withPOST:@"/doctor/Sportsprescription.MedicinePrescription/medicineStatistics" parameters:@{@"patient_id":self.patientid,@"medicine_id":medicineid} withSign:YES success:^(NSInteger code, NSString *message, id returnData) {
        if(code == 200){
            self.chartView.dataDic = returnData[@"column_chats"];
            self.chartView.currentIndex = self.index;
        }
    } error:^(NSError *error) {
        
    }];
}

-(LGMedicineRecordChartView *)chartView{
    if(!_chartView){
        _chartView = [[LGMedicineRecordChartView alloc] initWithFrame:CGRectMake(viewPix(16), viewPix(16), Screen_W-viewPix(32), viewPix(345))];
        _chartView.titleLabel.text = @"服药统计图";
        _chartView.tipButton.hidden = YES;
        _chartView.lineView.hidden = YES;
        _chartView.delegate = self;
    }
    return _chartView;
}

@end
